package com.yunmang.activity.setting;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.CompoundButton;

import com.kyleduo.switchbutton.SwitchButton;
import com.yunmang.R;
import com.yunmang.activity.BaseActivity;
import com.yunmang.app.AppConstant;
import com.yunmang.utils.SharedPreferencesUtils;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by Administrator on 2017/5/18.
 */
public class SwitchSetting extends BaseActivity {
    @InjectView(R.id.toolbar)
    Toolbar mToolbar;
    @InjectView(R.id.btn1)
    SwitchButton btn1;
    @InjectView(R.id.btn3)
    SwitchButton btn3;
    @InjectView(R.id.btn2)
    SwitchButton btn2;
    @InjectView(R.id.btn4)
    SwitchButton btn4;
    @Override
    public int getLayoutId() {
        return R.layout.activity_switch_set;
    }

    private void initToolbar() {
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("开关设置");
        mToolbar.setNavigationIcon(R.mipmap.ic_back);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void initView() {
        ButterKnife.inject(this);
        initToolbar();
    }

    @Override
    public void initData() {
        btn1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
//                if(b){
//                    SharedPreferencesUtils.saveParameter(context,"isAutoUpload_transport","true");
//                }else{
//                    SharedPreferencesUtils.saveParameter(context,"isAutoUpload_transport","false");
//                }
                AppConstant.isAutoUpload_transport=b;
            }
        });
        btn2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
//                if(b){
//                    SharedPreferencesUtils.saveParameter(context,"isAllScan_transport","true");
//                }else{
//                    SharedPreferencesUtils.saveParameter(context,"isAllScan_transport","false");
//                }
                AppConstant.isAllScan_transport=b;
            }
        });
        btn3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
//                if(b){
//                    SharedPreferencesUtils.saveParameter(context,"isAllScan_transport","true");
//                }else{
//                    SharedPreferencesUtils.saveParameter(context,"isAllScan_transport","false");
//                }
                AppConstant.isAutoUpload_arrive=b;
            }
        });
        btn4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
//                if(b){
//                    SharedPreferencesUtils.saveParameter(context,"isAllScan_transport","true");
//                }else{
//                    SharedPreferencesUtils.saveParameter(context,"isAllScan_transport","false");
//                }
                AppConstant.isAllScan_arrive=b;
            }
        });
    }
}
